//
//  MoyoungApi.swift
//  DaGlass
//
//  Created by 李然 on 2023/6/7.
//

import Foundation
import Moya

public enum MoyoungApi {
    
    /// 加密的国内天气
    case newAPIWeatherCN(city: String)
}

extension MoyoungApi: TargetType {
    
    public var baseURL: URL {
        return URL.init(string: "https://api.moyoung.com")!
    }
    
    public var path: String {
        switch self {
        case .newAPIWeatherCN: return "weather-report"
        }
    }
    
    public var method: Moya.Method {
        switch self {
        case .newAPIWeatherCN: return .get     
        }
    }
    
    public var task: Moya.Task {
        switch self {
        case .newAPIWeatherCN(let city):
            return .requestParameters(parameters: ["city": city], encoding: URLEncoding.default)
        }
    }
    
    public var headers: [String: String]? {
        return nil
    }
}
